package com.example.shiro.model.sys.mapper;

import com.example.shiro.model.sys.entity.UserRoleEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

/**
 * <p>
 * 用户角色连接表 Mapper 接口
 * </p>
 *
 * @author jatej
 * @since 2020-04-16
 */
public interface UserRoleMapper extends BaseMapper<UserRoleEntity> {

    /**
     * 通过用户ID查询角色标识集合
     * @param userId
     * @return
     */
    @Select("SELECT sr.role_remark FROM sys_role AS sr " +
            "   JOIN sys_user_role AS sur ON sr.role_id = sur.role_id " +
            "   WHERE sur.user_id = #{userId}")
    Set<String> getRoleNameById(Integer userId );

}
